/*
 * @Author: sympsel sympsel@outlook.com
 * @Date: 2025-09-28 19:12:33
 * @LastEditors: sympsel sympsel@outlook.com
 * @LastEditTime: 2025-09-29 21:50:52
 * @FilePath: \work25_9_28\src\test.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置:
 * https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include <cstddef>
#include <iostream>
#include <vector>
using std::cout;
using std::endl;
using std::string;

void print(std::vector<int>& v) {
    for (size_t i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}
void test1() {
    std::vector<int> v;
    v.push_back(1);
    v.push_back(2);
    v.push_back(3);
    v.push_back(4);
    cout << v.front() << endl;
    cout << v.back() << endl;
    print(v);
    auto it = v.begin();
    while (it != v.end()) {
        cout << *it << " ";
        ++it;
    }
}

void test2() {
    std::vector<int> v;
    v.push_back(1);
    v.push_back(2);
    v.push_back(3);
    v.push_back(4);
    v.reserve(100);
    cout << v.capacity() << endl;
    v.shrink_to_fit();
    cout << v.capacity() << endl;
    // auto arr = v.data();
    // for (size_t i = 0; i < v.size(); i++) {
    //     cout << arr[i] << " ";
    // }
    v.insert(v.begin(), 0);
    v.insert(v.end(), 5);
    cout << v.at(3) << endl;
    print(v);
    v.clear();
    cout << v.empty() << endl;
}

struct AAA {
    int a;
    int b;

    AAA(int a = 1, int b = 1) : a(a), b(b) {}
};

void test3() {
    std::vector<AAA> v = {AAA(1, 2), {2, 3}, AAA()};
    // for (AAA a : v) {
    //     cout << a.a << " " << a.b << endl;
    // }
    v.push_back({3, 4});
    v.emplace_back(4, 5);
    for (AAA a : v) {
        cout << a.a << " " << a.b << endl;
    }
}

void test4() {
    std::vector<int> v = {1, 2, 3, 4, 5};
    print(v);
    auto it = v.begin();
    cout << *it << endl;
    it = v.erase(it + 2);
    cout << *it << endl;
    int i = 0;
    print(v);
}

int main() {
    // test1();
    // test2();
    // test3();
    test4();
    return 0;
}